package club.looli.haoke.ad.api;

import club.looli.haoke.ad.entity.Ad;
import club.looli.haoke.ad.service.AdService;
import club.looli.haoke.common.vo.PageInfo;
import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <p>
 * Created by looli on 2020/7/12
 * </p>
 *
 * <p>
 * 远程接口实现
 * </p>
 *
 * @author looli
 * @since 2020/7/12
 */
@Service(version = "1.0.0")
public class ApiAdServiceImpl implements ApiAdService{

    @Autowired
    private AdService adService;

    @Override
    public PageInfo<Ad> queryAdList(Integer type, Integer page, Integer pageSize) {
        //封装分页信息
        Page<Ad> adPage = new Page<>(page, pageSize);

        //查询条件
        QueryWrapper<Ad> wrapper = new QueryWrapper<>();
        wrapper.eq("type",type);

        Page<Ad> selectPage = adService.page(adPage, wrapper);

        return new  PageInfo<Ad> (selectPage.getTotal(), selectPage.getCurrent(),selectPage.getSize(), selectPage.getRecords());
    }
}
